﻿// ZKYPJLIN.cpp: 实现文件
//

#include "ZKYPJLIN.h"
#include "afxdialogex.h"
#include "../../DIO/DIO.h"

CString strktqbh;
CString strzkbh;
using namespace DIO;


// ZKYPJLIN 对话框

IMPLEMENT_DYNAMIC(ZKYPJLIN, CDialogEx)

ZKYPJLIN::ZKYPJLIN(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_ZKYPJL, pParent)
{

}

ZKYPJLIN::~ZKYPJLIN()
{
}

void ZKYPJLIN::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_ZKYPJL_LIST, ZKYPJLLIST);
	DDX_Control(pDX, IDC_COMBO_ZKYPJLKTQBH, m_zkypjlktqbh);
	DDX_Control(pDX, IDC_COMBO_ZKYPJLZKBH, m_zkypjl_zkbh);
}


BEGIN_MESSAGE_MAP(ZKYPJLIN, CDialogEx)
	
	ON_CBN_SELCHANGE(IDC_COMBO_ZKYPJLKTQBH, &ZKYPJLIN::OnCbnSelchangeComboZkypjlktqbh)
	ON_CBN_SELCHANGE(IDC_COMBO_ZKYPJLZKBH, &ZKYPJLIN::OnCbnSelchangeComboZkypjlzkbh)
	ON_BN_CLICKED(IDC_ZKYPJL_ADD, &ZKYPJLIN::OnBnClickedZkypjlAdd)
END_MESSAGE_MAP()


// ZKYPJLIN 消息处理程序

BOOL ZKYPJLIN::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	// TODO:  在此添加额外的初始化

	CString GKTitleName;
	GKTitleName = "钻孔样品记录表";
	DWORD dwStyle = ZKYPJLLIST.GetExtendedStyle();
	//dwStyle = ZKYPJLLIST.GetExtendedStyle();
	ZKYPJLLIST.SetExtendedStyle(dwStyle | LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
	ZKYPJLLIST.InsertColumn(0, _T("MDBTAD（勘探区编号）"), LVCFMT_CENTER, 200);
	ZKYPJLLIST.InsertColumn(1, _T("GCJCBN(钻孔编号)"), LVCFMT_CENTER, 140);
	ZKYPJLLIST.InsertColumn(2, _T("PKHFB(样品编号)"), LVCFMT_CENTER, 140);
	ZKYPJLLIST.InsertColumn(3, _T("TKACCF(采样起始孔深)"), LVCFMT_CENTER, 140);
	ZKYPJLLIST.InsertColumn(4, _T("TKACCG(采样终止孔深)"), LVCFMT_CENTER, 140);
	ZKYPJLLIST.InsertColumn(5, _T("TKBAML(样长)"), LVCFMT_CENTER, 140);
	ZKYPJLLIST.InsertColumn(6, _T("GCLCAA(岩矿心长度)"), LVCFMT_CENTER, 140);
	ZKYPJLLIST.InsertColumn(7, _T("HXGID(样品类型)"), LVCFMT_CENTER, 140);

	m_zkypjlktqbh.AddString(TEXT("选择勘探区编号"));
	m_zkypjlktqbh.SetCurSel(0);
	m_zkypjlktqbh.AddString(TEXT("654324000000001"));
	//m_zkypjlktqbh.AddString(TEXT("3"));

	m_zkypjl_zkbh.AddString(TEXT("选择钻孔编号"));
	m_zkypjl_zkbh.SetCurSel(0);
	m_zkypjl_zkbh.AddString(TEXT("JZK1306"));
	m_zkypjl_zkbh.AddString(TEXT("ZK0103"));
	m_zkypjl_zkbh.AddString(TEXT("ZK0104"));
	m_zkypjl_zkbh.AddString(TEXT("ZK0105"));
	m_zkypjl_zkbh.AddString(TEXT("JZK106"));
	m_zkypjl_zkbh.AddString(TEXT("ZK0107"));
	m_zkypjl_zkbh.AddString(TEXT("ZK0108"));
	m_zkypjl_zkbh.AddString(TEXT("ZK0109"));


	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}
//
//void ZKYPJLIN::OnBnClickedZktpjlAdd()
//{
//	// TODO: 在此添加控件通知处理程序代码
//	SampleRecord_ST drill;
//
//	/*CString ZKYPJL_ktqbh;
//	GetDlgItem(IDC_ZKYPJL_KTQBH)->GetWindowText(ZKYPJL_ktqbh);
//	drill.kantanqu_no = ZKYPJL_ktqbh;
//
//	CString ZKYPJL_zkbh;
//	GetDlgItem(IDC_ZKYPJL_ZKBH)->GetWindowText(ZKYPJL_zkbh);
//	drill.drill_no = ZKYPJL_zkbh;*/
//
//	CString ZKYPJL_ypbh;
//	GetDlgItem(IDC_ZKYPJL_YPBH)->GetWindowText(ZKYPJL_ypbh);
//	drill.sample_no = ZKYPJL_ypbh;
//
//	CString ZKYPJL_cyqsks;
//	GetDlgItem(IDC_ZKYPJL_CYQSKS)->GetWindowText(ZKYPJL_cyqsks);
//	double begin = atof(ZKYPJL_cyqsks);
//	drill.begin = begin;
//
//	CString ZKYPJL_cyzzks;
//	GetDlgItem(IDC_ZKYPJL_CYZZKS)->GetWindowText(ZKYPJL_cyzzks);
//	double end = atof(ZKYPJL_cyzzks);
//	drill.end = end;
//
//
//	CString ZKYPJL_yc;
//	GetDlgItem(IDC_ZKYPJL_YC)->GetWindowText(ZKYPJL_yc);
//	double sample_length = atof(ZKYPJL_yc);
//	drill.sample_length = sample_length;
//
//	CString ZKYPJL_ykxcd;
//	GetDlgItem(IDC_ZKYPJL_YKXCD)->GetWindowText(ZKYPJL_ykxcd);
//	double core_length = atof(ZKYPJL_ykxcd);
//	drill.core_length = core_length;
//
//	CString ZKYPJL_yplx;
//	GetDlgItem(IDC_ZKYPJL_YPLX)->GetWindowText(ZKYPJL_yplx);
//	double type = atof(ZKYPJL_yplx);
//	drill.type = type;
//
//
//	int nindex = ZKYPJLLIST.InsertItem(3, ZKYPJL_ypbh);
//	ZKYPJLLIST.SetItemText(nindex, 1, ZKYPJL_cyqsks);
//	ZKYPJLLIST.SetItemText(nindex, 2, ZKYPJL_cyzzks);
//	ZKYPJLLIST.SetItemText(nindex, 3, ZKYPJL_yc);
//	ZKYPJLLIST.SetItemText(nindex, 4, ZKYPJL_ykxcd);
//	ZKYPJLLIST.SetItemText(nindex, 5, ZKYPJL_yplx);
//
//
//	UserInsertDMZK04061(drill);
//}

void ZKYPJLIN::OnCbnSelchangeComboZkypjlktqbh()
{
	// TODO: 在此添加控件通知处理程序代码
	//获取某个索引
	int index = m_zkypjlktqbh.GetCurSel();
	//获得勘探区编号
	m_zkypjlktqbh.GetLBText(index, strktqbh);
}


void ZKYPJLIN::OnCbnSelchangeComboZkypjlzkbh()
{
	// TODO: 在此添加控件通知处理程序代码
	//获取某个索引
	int index = m_zkypjl_zkbh.GetCurSel();
	//获得勘探区编号
	m_zkypjl_zkbh.GetLBText(index, strzkbh);
}


void ZKYPJLIN::OnBnClickedZkypjlAdd()
{
	// TODO: 在此添加控件通知处理程序代码
	// TODO: 在此添加控件通知处理程序代码
	SampleRecord_ST drill;

	/*CString ZKYPJL_ktqbh;
	GetDlgItem(IDC_ZKYPJL_KTQBH)->GetWindowText(ZKYPJL_ktqbh);
	drill.kantanqu_no = ZKYPJL_ktqbh;

	CString ZKYPJL_zkbh;
	GetDlgItem(IDC_ZKYPJL_ZKBH)->GetWindowText(ZKYPJL_zkbh);
	drill.drill_no = ZKYPJL_zkbh;*/

	CString ZKYPJL_ypbh;
	GetDlgItem(IDC_ZKYPJL_YPBH)->GetWindowText(ZKYPJL_ypbh);
	drill.sample_no = ZKYPJL_ypbh;

	CString ZKYPJL_cyqsks;
	GetDlgItem(IDC_ZKYPJL_CYQSKS)->GetWindowText(ZKYPJL_cyqsks);
	double begin = atof(ZKYPJL_cyqsks);
	drill.begin = begin;

	CString ZKYPJL_cyzzks;
	GetDlgItem(IDC_ZKYPJL_CYZZKS)->GetWindowText(ZKYPJL_cyzzks);
	double end = atof(ZKYPJL_cyzzks);
	drill.end = end;


	CString ZKYPJL_yc;
	GetDlgItem(IDC_ZKYPJL_YC)->GetWindowText(ZKYPJL_yc);
	double sample_length = atof(ZKYPJL_yc);
	drill.sample_length = sample_length;

	CString ZKYPJL_ykxcd;
	GetDlgItem(IDC_ZKYPJL_YKXCD)->GetWindowText(ZKYPJL_ykxcd);
	double core_length = atof(ZKYPJL_ykxcd);
	drill.core_length = core_length;

	CString ZKYPJL_yplx;
	GetDlgItem(IDC_ZKYPJL_YPLX)->GetWindowText(ZKYPJL_yplx);
	double type = atof(ZKYPJL_yplx);
	drill.type = type;


	int nindex = ZKYPJLLIST.InsertItem(3, ZKYPJL_ypbh);
	ZKYPJLLIST.SetItemText(nindex, 1, ZKYPJL_cyqsks);
	ZKYPJLLIST.SetItemText(nindex, 2, ZKYPJL_cyzzks);
	ZKYPJLLIST.SetItemText(nindex, 3, ZKYPJL_yc);
	ZKYPJLLIST.SetItemText(nindex, 4, ZKYPJL_ykxcd);
	ZKYPJLLIST.SetItemText(nindex, 5, ZKYPJL_yplx);


	UserInsertDMZK04061(drill);
}
